package com.chao.tlias.controller;
/**
 * 登录控制器
 */

import com.chao.tlias.Pojo.Emp;
import com.chao.tlias.Pojo.Result;
import com.chao.tlias.Pojo.loginInfo;
import com.chao.tlias.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {

    @Autowired
    private EmpService empService;

    @PostMapping("/login")
    public Result login(@RequestBody Emp emp) {
        log.info("登录信息：{}", emp);

        loginInfo info= empService.login(emp);
        if (info != null) {
            return Result.success(info);
        }else {
            return Result.error("用户名或密码错误");
        }

    }
}
